package ran.friend.controller.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ran.constants.HttpConstants;
import ran.controller.BaseController;
import ran.entity.Result;
import ran.entity.TableDataInfo;
import ran.friend.domain.exam.dto.ExamEnterDTO;
import ran.friend.domain.exam.dto.ExamQueryDTO;
import ran.friend.domain.exam.vo.ExamVO;
import ran.friend.service.user.IUserExamService;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ran
 * Date: 2025-11-14
 * Time: 19:23
 */
@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {
    @Autowired
    private IUserExamService userExamService;

    // 竞赛报名, 参数是token 和 竞赛id
    @PostMapping("/enter")
    public Result<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token, @RequestBody ExamEnterDTO examEnterDTO) {
        return toResult(userExamService.enter(token, examEnterDTO.getExamId()));
    }

    // 我的竞赛列表
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
        return userExamService.list(examQueryDTO);
    }
}
